package cn.richard.demo.ruleengine.config;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import cn.richard.demo.ruleengine.bean.EasyRule;
import lombok.Data;

@Component
@ConfigurationProperties(prefix = "ex-channel-rule")
@Data
public class NacosConfigExChannelRule {
	private List<String> channels = new ArrayList<>();
	private List<EasyRule> rules = new ArrayList<>();
}
//dataId: rule-local.yml
//group: RULE
//namespace: public
/*
person-demo-rule: 
  rules: 
  - name: age rule
    description: Check if person's age is > 18 and marks the person as adult
    priority: 10
    condition: person.age > 18
    actions: 
    - person.setAdult(true);
    - System.out.println("<< Sure, enjoy yourself !");

  - name: meet Tom
    description: meet Tom rule for test
    priority: 20
    condition: person.age == 'Tom'
    actions: 
    - System.out.println("<< Tom, I catch you !");

  - name: always true
    description: always true rule for test
    priority: 30
    condition: 1 == 1
    actions: 
    - System.out.println("<< trigger always true rule !");

ex-channel-rule: 
  channels: 
  - AWX
  - BC
  - CC
  - QY

  rules: 
  - name: amt_qy_1000000
    description: 单笔量>=10W，选择QY
    priority: 10
    condition: trans.amt >= 1000000
    actions: 
    - trans.channelCode = "QY";

  - name: conversion_type_T1_BC
    description: 交割日T1则选择BC
    priority: 20
    condition: trans.conversionType == 'T1'
    actions: 
    - trans.channelCode = "BC";

  - name: EUR_CC
    description: EUR选择CC
    priority: 31
    condition: trans.sourceCur=='EUR'
    actions: 
    - trans.channelCode = "CC";

  - name: other_choise_AWX
    description: 其他情况选择都是AWX
    priority: 30
    condition: 1 == 1
    actions: 
    - trans.channelCode = "AWX";
    - System.out.println("其他默认选择AWX v2");
*/
